package study.day7;
//1.引入流
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class T2 {
    public static void main(String[] args) {
        //字节流读取文本文件
        //2.创建对象
        FileInputStream fis = null;
        try{
            fis=new FileInputStream("C:\\Users\\DELL\\IdeaProjects\\file\\1.txt");
            //3.读取文件
            byte[] bytes=new byte[1024];
            while(fis.available()!=0){
                //没有到达流的末尾
                int data = fis.read(bytes);//实际的数据
                String str=new String(bytes,0,data);
                System.out.println(str);
            }
        }catch(FileNotFoundException e){
            System.out.println("File not found");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            //4.关闭流
            try{
                fis.close();
            }catch (IOException e){
                e.printStackTrace();
            }
        }
    }
}
